package com.bobo.dao.user;

import com.bobo.annotations.Prm;
import com.bobo.dao.BaseDaoImpl;
import com.bobo.model.User;

import java.lang.reflect.InvocationTargetException;

import java.util.List;

/**
 * Created by bobo on 16-11-10.
 */
public class UserDaoImpl extends BaseDaoImpl<User> implements IUserDao {

    @Override
    public Integer create(User user) {
//        return super.create(user);
        return null;
    }

    @Override
    public boolean upd(User user) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        return false;
//        return super.update(user);
    }

    @Override
    public boolean updPwd(User user) {
        return false;
    }

    @Override
    public User getUser(@Prm("t_user_id") Integer id) {
//        String sql = "SELECT *FROM t_user WHERE id=?";
//        ResultSet rs = getObject(sql, 1);
//        User user = new User();
//        try {
//            while (rs.next()){
//                user.setId(rs.getInt("id"));
//                user.setSex(rs.getInt("sex"));
//            }
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
        String sql = "SELECT tu.*" +
//                "  tu.id, " +
//                "  tu.name, " +
//                "  tu.sex, " +
//                "  tu.birthday, " +
                "  tp.id, " +
                "  tp.name" +
                " FROM t_user tu, t_person tp " +
                " WHERE 1 = 1 AND tu.person_id = tp.id AND tu.id = ?";
        Object obj = super.getObj(sql, User.class, id);
        return (User) obj;
    }

    @Override
    public Integer getCount(Integer status) {
        return null;
    }

    @Override
    public List<User> getUsers(Integer current, Integer pageSize, Integer status) {

        return super.getObjs("");
    }

    @Override
    public User userCompare(String name, String email, String password) {
        return null;
    }

    @Override
    public User updQuery(Integer id, String password) {
        return null;
    }
}
